package com.blog.wl2023.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * @author wule
 * @date 2023-09-28  21:49
 * @desc 文章评论
 */
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "articlecomment")
@Data
public class ArticleComment extends BaseEntity {

	@Column(name = "article_id")
	private String articleId;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "user_id", referencedColumnName = "uuid")
	private User user;

	@Column(name = "comment_content")
	private String commentContent;

	@Column(name = "create_time")
	private Date createTime;

	/*是否删除 1:是 0:否*/
	@Column(name = "is_delete")
	private Integer isDelete;

	@Column(name = "p_id")
	private String pId;

	@PrePersist
	public void prePersist() {
		this.createTime = new Date();
	}

	//拿到所有用户集合(名字,头像,id) :循环匹配上用户名字,
	@Transient
	private String imageUrl;
	@Transient
	private String userId;
	@Transient
	private String username;

	@Transient
	private List<ArticleComment> childComment;

}

